/*Linked List
Author:Q.DAI
Date:22>01>2025
DD>MM>YYYY
*/

#include "toolList.h"
#include "stdlib.h"
#include "stdio.h"

#include "userBeep.h"
#include "userLed.h"

/******************
Function Name: Addlist 
Parameter:	*pHead Lind List Head Node
						*p Object Node
*******************/
void Addlist(ListNode_t *pHead, void *p)
{
    /*Creat a new Node*/
    ListNode_t *newNode = (ListNode_t *)malloc(sizeof(ListNode_t));
if(newNode==NULL)  /*Input Check*/
{
//	MALLOC_CHECKED_FAILD();
	LED_STAUS_SYS_INIT_FAULT();
	while(1)
		;
	return;
}

    ListNode_t *tmpHead = pHead;/* List Node Head is a globe variable,start at NULL, 
																	 will be update as a ObjectNode add in list  */

    newNode->Node_ptr = p; /*add object Node ptr in*/
    newNode->Next_ptr = NULL; 
    if(tmpHead->Node_ptr == NULL) /*if Node Head hasn't Been Update, also, the Object ptr is the first Node*/
    {
        tmpHead->Node_ptr = p; /*Update List Head (a globle Variable)*/
        tmpHead->Next_ptr = NULL;
    }
    else
    {
        while(tmpHead->Next_ptr != NULL)
        {/*move to the last Node*/
            tmpHead = tmpHead->Next_ptr;
        }
        tmpHead->Next_ptr = newNode;
    }
}




